package com.mini.cn.goods.observer;

import com.mini.cn.goods.common.observes.IObserver;
import com.mini.cn.goods.common.observes.Message;
import com.mini.cn.goods.common.observes.YaKashMessageManager;
import com.mini.cn.goods.config.MessageConfig;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;


/**
 * Created by fly on 17/7/13.
 */
@Component("newuserob")
public class NewUserObserver implements IObserver {

    @PostConstruct
    public void init() {
        YaKashMessageManager.INSTANCE.registerMessage(String.valueOf(MessageConfig.REGISTER),this);
        System.out.println("init NewUserObserver");
    }

    //  how  validate the  destory method is  a question
    @PreDestroy
    public void cleanUp() {
        YaKashMessageManager.INSTANCE.unRegisterMessage(String.valueOf(MessageConfig.REGISTER),this);
        //System.out.println("cleanUp");
    }


    public void onNoticeMessage(Message message) {

        System.out.println("new user onNoticeMessage");
    }

    @Override
    public String getObserverName() {
        return "newuserob";
    }
}
